package com.obggtc.picture.utils;


import cn.hutool.core.collection.CollUtil;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class CommonUtils {

    //全局变量
    public static Map<String, List<String>> DOWNLOAD_IMG_MESSAGE = new HashMap<>();

    public static String status = "0";

    public void set(String key,List<String> value){
        DOWNLOAD_IMG_MESSAGE.put(key,value);
    }

    public List<String> get(String key){
        List<String> list = DOWNLOAD_IMG_MESSAGE.get(key);
        list = CollUtil.isEmpty(list)? new ArrayList<>() : list;
        return DOWNLOAD_IMG_MESSAGE.put(key,list);
    }

    public boolean containsKey(String key){
        boolean b = DOWNLOAD_IMG_MESSAGE.containsKey(key);
        return b;
    }

    public void clear(String key){
      List<String> list =  DOWNLOAD_IMG_MESSAGE.containsKey(key) ? DOWNLOAD_IMG_MESSAGE.get(key) : new ArrayList<>();
      list.clear();
      DOWNLOAD_IMG_MESSAGE.put(key,list);
    }
}
